<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<html lang="zh">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width,initial-scale=1.0,maximum-scale=1,minimum-scale=1,user-scalable=no" media="(device-height: 568px)">
    <meta name="apple-mobile-web-app-capable" content="yes">
    <meta name="HandheldFriendly" content="True">
    <meta name="apple-mobile-web-app-status-bar-style" content="black">
    <title></title>
    <link rel="stylesheet" type="text/css" media="all" href="../css/reset.css" />
    <link rel="stylesheet" type="text/css" media="all" href="../css/swiper.min.css" />
    <link rel="stylesheet" type="text/css" media="all" href="../css/style.css" />

    <script type="text/javascript" src="../js/common/jquery-2.1.1.min.js"></script>
    <script src="../js/common/swiper.jquery.js" type="text/javascript"></script>
    <script type="text/javascript" src="../js/common/jquery.SuperSlide.2.1.1.js"></script>
    <script src="../js/common/js.js" type="text/javascript"></script>
    <script src="../js/ring_add.js" type="text/javascript"></script>
    <!-- <script src="../js/common/city.js" type="text/javascript"></script> -->
</head>

<body>
    <!-- 顶部 -->
    <div class="header">
        <a href="fox://setBack" class="hele"></a>
        <h1 class="hetitle">发布</h1>
    </div>
    <div id="page" class="page m2">
        <div class="ring_add">
            <textarea class="radd_text" placeholder="请输入内容"></textarea>
            <form class="ring_picd" method="post" enctype="multipart/frm-data">
                <div class="ring_pic_itme" id="ring_pic_itme">
                    <img src="../img/add.png" alt="" class="ring_pic" id="headImg" />
                    <input type="file" name="file" class="ring_input" id="fileInput" onchange="showPic(this)" />
                </div>
            </form>

        </div>
        <a href="javascript:dialog('#d1');" class="ringadlink typelist">发布类型<span class="ringadtext" id="ringadtext1"></span></a>
        <a href="javascript:dialog('#d2');" class="ringadlink cityList">所在省份<span class="ringadtext" id="ringadtext2"></span></a>
        <input type="hidden" class="province">
        <input type="hidden" class="city">
        <input type="hidden" class="county">
        <!-- 地址 -->
        <input type="hidden" class="hiddenadd">

        <button class="submit">发布</button>
    </div>

    <!-- 遮罩 -->
    <div class="mask" onclick="dialogClose()"></div>
    <!--类型弹窗-->
    <div class="dialog" id="d1" style="bottom:0;top:auto;height:inherit;">
        <div class="sendTypeLists"></div>
    </div>
    <!--省份弹窗-->
    <div class="dialog" id="d2" style="bottom:0;top:auto;height:inherit;">
        <div class="cityLists"></div>
    </div>
</body>
<script type="text/javascript">
    //点击显示图片
    function showPic(data) {
        // 图片上传ajax
        let formData = new FormData($(".ring_picd")[0]);
        formData.append("method", 'Uploads|upload_img');
        formData.append("type", 1);
        $.ajax({
            url: url,
            type: 'POST',
            data: formData,
            async: false,
            cache: false,
            contentType: false,
            processData: false,
            dataType: "json",
            success: function(res) {
                // console.log(res);
                let arr = [];
                if (res.status == 1) {
                    let data = res.data;

                    //新加图片
                    let html = '<div class="ring_pic_itme">'
                    html += '<img src="' + data.thumb + '" alt="" class="ring_pic"/>'
                    html += '<img src="../img/coindpic2.png" alt="" class="coindpic2"  onclick="remove(this)"/><input type="hidden" class="fileinput" value=""/></div>'
                    $("#ring_pic_itme").before(html);

                    let len = $('.ring_pic_itme').length - 2;
                    // // console.log(len);
                    $(".ring_pic_itme").eq(len).find(".fileinput").attr('data-path', data.path);
                    $(".ring_pic_itme").eq(len).find(".fileinput").attr('data-thumb', data.thumb);
                } else if (res.status == 2) {
                    alert(res.message);
                    location.href = "fox://logout";
                } else {
                    alert(res.message);
                }
            }
        });
    }

    //删除图片
    function remove(dd) {
        var _this = dd;
        $(_this).parent().remove();
    }

    //弹窗取消按钮
    // $(document).on('click', function() {
    //     dialogClose();
    // })
    //防止冒泡
    $(document).on('click', ".typeItem", function(event) {
        event.stopPropagation();
    });
    $(document).on('click', ".cityItem", function(event) {
        event.stopPropagation();
    });
</script>

</html>